home *** CD-ROM | disk | FTP | other *** search
- /*
- PanelHack - a hack on the Apple Network Server (AIX)
- ====================================================
-
- Mike Webb
- Stuart S. Schmukler
- Rob Hagopian
- Oleg Kiselyov
- and random other folk that helped us get the machine up, but weren't around
- when I typed in this comment.
-
- This hack writes silly strings to the display panel on the front of
- the Apple Network Server (AIX) box.
-
- panelhack -h dumps the panel hack usage string to the display panel
- panelhack <string> dumps <string> to the display panel
- panelhack dumps a random string to the display panel
-
- You need root privilige to do this.
-
- This is a hack. It is only a hack. It does nasty things to NVRAM, so be careful
- if you twiddle things so that you don't fry your system by writing into some other
- part of NVRAM.
-
- */
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/cfgdb.h>
- #include <sys/cfgodm.h>
- #include <cf.h>
- #include <fcntl.h>
-
- #define _APPLE
- #include <sys/mdio.h>
-
- #define max(x, y) ((x) > (y) ? (x) : (y))
- #define min(x, y) ((x) < (y) ? (x) : (y))
- #define PANEL "/dev/nvram"
-
- /* main function code */
-
- static
- char* strings[]=
- {
- " Welcome to MacHack This is Panel Hack, ---- the Un-PDA ----",
- "Yes, but this hack goes to eleven.",
- "login: \001",
- "segmentation fault, core dumped",
- "Dammit Jim, I'm a display panel not a console.",
- "C> _",
- "(dbx) \001",
- "] \001",
- "$ \001",
- "Dave, my mind is going. I can feel it going Dave. Dave? dave? d a v e...",
- "Panelhack 1.0.99a update 233 rel 5.2b"
- };
-
- main(argc, argv, envp)
- int argc;
- char *argv[];
- char *envp[];
- {
-
- char gStr[80];
- char buffer[32767];
-
- MACH_DD_IO mddRecord;
-
- int fd;
-
- int idx = 0;
- int len;
-
- if (argc > 1)
- {
- strcpy(buffer, argv[1]);
-
- if (strcmp(buffer, "-h") == 0)
- {
- strcpy(buffer, " Usage: panelhack [-h|<String>]");
- }
- }
- else
- {
- /* And people think Lisp has too many parentheses... */
-
- strcpy(buffer, strings[(time(0) % (sizeof(strings) / sizeof(strings[0])))]);
- }
-
- len = strlen(buffer);
-
- strncpy(gStr, &buffer[idx], min(len, sizeof(gStr)));
- printf("%s\n", gStr);
-
- if (0 > (fd = open(PANEL, O_RDWR)))
- {
- exit -1;
- }
-
- mddRecord.md_ofstring = (unsigned long)gStr;
- mddRecord.md_ofbuflen = sizeof(gStr);
- mddRecord.md_incr = MV_BYTE;
- mddRecord.md_ofbuf = gStr;
-
- if (0 > ioctl(fd, MIOLCDSTRING, &mddRecord))
- {
- exit -2;
- }
- }
-